package cn.eleven.mapper;

import cn.eleven.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapperOne extends BaseMapper<User> {

    @Select("SELECT * FROM user WHERE id = #{id}")
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "user_id", property = "userId"),
            // 注意这里的 one 注解应该放在 Results 注解内部
            @Result(column = "user_id", property = "forumPost",
                    one = @One(select = "cn.eleven.mapper.ForumPostMapper.selectById"))
    })
    User getUserById(int id);
}